<?php include ('dbcon.php'); ?>
<div id="divRight" >
	</br>
     	<div class="rightNav">
		<h3 class="headerbar">Tài khoản</h3>

<?php
	if(!isset($_SESSION['myname']))
	{
		echo '
			<form id="tutorial" action="xulydangnhap.php" method="post">
			<br>
				<label>Tên đăng nhập</label>
				<input type="text" name="name" id="name" /><br>
				<label>Mật khẩu</label>
				<input type="password" name="email" id="email"/><br>
				<br>
				<p class="submit"><input id="submit" class="css" type="submit" value="Đăng nhập" />';
				echo "<br>";
				echo "<br>";
			echo '<a href="javascript:tb_show(';
		echo "'Đăng ký','./TB/dieukhoandk.php?KeepThis=true&amp;TB_iframe=true&amp;width=450&amp;height=520&amp;scrollbar=0',false);";
		echo '" title=';
		echo "'Login'>Đăng ký</a> | ";
		echo '<a href="javascript:tb_show(';
		echo "'Quên mật khẩu','./TB/quenmk.php?KeepThis=true&amp;TB_iframe=true&amp;width=450&amp;height=520&amp;scrollbar=0',false);";
		echo '" title=';
		echo "'Quên mật khẩu'>Quên mật khẩu</a>
			</form> 
			
			
			<div class='success' ></div>
			";
}
	else
	{
		echo '<p class="success">Đăng nhập dưới tên <span style="color:blue" >'.$_SESSION['myname'].'</span>.<br>
				<a href="thongtinkh.php">Thông tin tài khoản</a><br>
				<a href="napthe.php">Nạp thẻ</a><br>
				<a href="logout.php">Đăng xuất</a> !</p>'; 
	}
?>

		 </br>

		<?php $id = isset($_GET['id']) ? $_GET['id'] : 1; ?>

		<h3 class="headerbar">Sản Phẩm Bán Chạy</h3>

		<center>  
		<table class="show1" width="100%" border="0" align="center" >
        <tr align="center">
         <?php
		 $x = 0;
        // put your code here
        $DT = mysql_query("SELECT a.masp,a.urlhinh,a.tensp,a.gia from sanpham a,donhangchitiet b where a.masp = b.masp group by b.masp ORDER BY SUM( b.soluong ) DESC limit 0,5 ");
		while ($row = mysql_fetch_array($DT))
		{
			$x+=1;
		?>
        <td  class="show1">
		  
		    <?php echo "<font color='#000' size='2px'><label><strong><u><p><a href='detail.php?madt=$row[0]'> $row[2] </strong></label></a></p></u></font>";?>
	      
		  <p><br/>
	      <?php echo "<a href='detail.php?madt=$row[0]'><img src ='$row[1]' width ='90' height ='120'></a>"?>
          </p>
		  <br/>
		    <font color="#FF0000" size="2px"><label><strong><?php echo "". number_format($row[3],0) ."đ";?>
	        </strong></label></font><br>
           
          
          <br>
		 </td>
		 <?php
		 if($x ==1)
		 {
			 $x = 0;
			 ?>
             </tr>
			 <tr align="center">
         <?php
        }
	
		}  
		?>
        </table> 
        
        <h3 class="headerbar">Sản Phẩm Xem Nhiều </h3>

		<center>  
		<table class="show1" width="100%" border="0" align="center" >
        <tr align="center">
         <?php
		 $x = 0;
        // put your code here
        $DT = mysql_query("SELECT a.masp,a.urlhinh,a.tensp,a.gia from sanpham a group by (a.solanxem) DESC limit 0,5 ");
		while ($row = mysql_fetch_array($DT))
		{
			$x+=1;
		?>
        <td  class="show1">
		  
		    <?php echo "<font color='#000' size='2px'><label><strong><u><p><a href='detail.php?madt=$row[0]'> $row[2] </strong></label></a></p></u></font>";?>
	      
		  <p><br/>
	      <?php echo "<a href='detail.php?madt=$row[0]'><img src ='$row[1]' width ='90' height ='120'></a>"?>
          </p>
		  <br/>
		    <font color="#FF0000" size="2px"><label><strong><?php echo "". number_format($row[3],0) ."đ";?>
	        </strong></label></font><br>
           
          
          <br>
		 </td>
		 <?php
		 if($x ==1)
		 {
			 $x = 0;
			 ?>
             </tr>
			 <tr align="center">
         <?php
        }
	
		}  
		?>
        </table> 
        </center>		
		</div>
    </div>